< previous page page_458 next page >

Page 458
e10a6a0a59f035e870d90cca05b85fce.gif
' Rotate around the Y axis to place the
' center of projection in the Y-Z plane.
m3Identity M2

' If d1 = 0 then the center of projection 
' already lies in the Y axis and thus the Y-Z plane. 
If d1 <> 0 Then 
    M2(1, 1) = cos1
    M2(1, 3) = -sin1
    M2(3, 1) = sin1
    M2(3, 3) = cos1
End If

' Rotate around the X axis to place the
' center of projection in the Z axis.
m3Identity M3

' If d2 = 0 then the center of projection
' lies at the origin. This makes projection
' impossible.
If d2 <> 0 Then
    M3(2, 2) = cos2
    M3(2, 3) = sin2
    M3(3, 2) = -sin2
    M3(3, 3) = cos2
End If

' Apply the rotations to the UP vector. 
up1(1) = ux
up1(2) = uy
up1(3) = uz
up1(4) = 1
m3Apply up1, M2, up2
m3Apply up2, M3, up1

' Rotate around the Z axis to put the UP
' vector in the Y-Z plane.
d3 = Sqr(up1(1) * up1(1) + up1(2) * up1(2))
m3Identity M4

' If d3 = 0 then the UP vector is a zero
' vector so do nothing.
If d3 <> 0 Then
    sin3 = up1(1) / d3
    cos3 = up1(2) / d3
    M4(1, 1) = cos3
    M4(1, 2) = sin3
    M4(2, 1) = -sin3
    M4(2, 2) = cos3
End If

 
< previous page page_458 next page >